package com.zhuozhengsoft.pageoffice6springboot2back.controller.insertSeal;

import com.zhuozhengsoft.pageoffice.FileSaver;
import com.zhuozhengsoft.pageoffice.PDFCtrl;
import com.zhuozhengsoft.pageoffice6springboot2back.util.GetDirPathUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@RestController
@RequestMapping(value = "/InsertSeal/PDF/")
public class PDFInsertSealController {
    //获取doc目录的磁盘路径
    private final String dir = GetDirPathUtil.getDirPath() + "static/doc/";

    public PDFInsertSealController() throws IOException {
    }

    @RequestMapping(value = "AddSeal/PDF1")
    public String AddSeal_PDF1(HttpServletRequest request) {
        PDFCtrl pdfCtrl1 = new PDFCtrl(request);
        pdfCtrl1.webOpen("/doc/InsertSeal/PDF/AddSeal1/test.pdf");
        return pdfCtrl1.getHtml();
    }

    @RequestMapping(value = "AddSeal/PDF2")
    public String AddSeal_PDF2(HttpServletRequest request) {
        PDFCtrl pdfCtrl1 = new PDFCtrl(request);
        pdfCtrl1.webOpen("/doc/InsertSeal/PDF/AddSeal2/test.pdf");
        return pdfCtrl1.getHtml();
    }

    @RequestMapping(value = "AddSeal/PDF3")
    public String AddSeal_PDF3(HttpServletRequest request) {
        PDFCtrl pdfCtrl1 = new PDFCtrl(request);
        pdfCtrl1.webOpen("/doc/InsertSeal/PDF/AddSeal3/hetong.pdf");
        return pdfCtrl1.getHtml();
    }

    @RequestMapping(value = "DeleteSeal/PDF")
    public String DeleteSeal_PDF(HttpServletRequest request) {
        PDFCtrl pdfCtrl1 = new PDFCtrl(request);
        pdfCtrl1.webOpen("/doc/InsertSeal/PDF/DeleteSeal/test.pdf");
        return pdfCtrl1.getHtml();
    }

    @RequestMapping(value = "AddSign/PDF1")
    public String AddSign_PDF1(HttpServletRequest request) {
        PDFCtrl pdfCtrl1 = new PDFCtrl(request);
        pdfCtrl1.webOpen("/doc/InsertSeal/PDF/AddSign1/test.pdf");
        return pdfCtrl1.getHtml();
    }


    @RequestMapping("AddSeal/save")
    public void save(HttpServletRequest request, HttpServletResponse response,String savePath) {
        FileSaver fs = new FileSaver(request, response);
        fs.saveToFile(dir + savePath + fs.getFileName());
        fs.close();
    }


    @RequestMapping("AddSign/save")
    public void save2(HttpServletRequest request, HttpServletResponse response,String savePath) {
        FileSaver fs = new FileSaver(request, response);
        fs.saveToFile(dir + savePath + fs.getFileName());
        fs.close();
    }

}
